fix(json): quote object keys in schema output#1023
fix(json): quote object keys in schema output#1023CastawayEGR wants to merge 2 commits intortk-ai:developfrom
Conversation
Both functions formatted JSON object keys without double quotes, producing invalid JSON that broke jq, python json.load(), etc. Fixes rtk-ai#1015
📊 Automated PR Analysis
SummaryFixes invalid JSON output from compact_json() and extract_schema() by wrapping object keys in double quotes. Previously, keys were emitted without quotes, breaking standard JSON parsers like jq and Python's json.load(). Review Checklist
Linked issues: #1015 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
em0t
left a comment
There was a problem hiding this comment.
I tested this locally against current master and this branch, and I still see blocking issues before merge.
First, rtk json <file> still does not produce valid JSON for object output because object entries are not comma-separated, so jq and python -c 'import json,sys; json.load(sys.stdin)' still fail on simple cases.
Second, keys are wrapped in quotes but not escaped, so inputs containing " or \ in object keys still produce invalid output.
I also don’t think --schema currently satisfies the “valid JSON” claim, because tokens like int, string, and [int] (3) are not JSON values.
I’d either narrow the PR description to “quote keys in display output” or extend the implementation/tests to cover actual JSON-valid output.
Object keys in
compact_json()andextract_schema()were missing double quotes, producing invalid JSON that breaksjq,python3 json.load(), etc.Wraps all key formatting in
"key":instead ofkey:.Fixes #1015